package com.ruoyi.project.per.emp.domain;

import com.ruoyi.framework.aspectj.lang.annotation.Excel;
import com.ruoyi.framework.aspectj.lang.annotation.Excels;
import com.ruoyi.framework.web.domain.BaseEntity;
import com.ruoyi.project.system.dept.domain.Dept;
import com.ruoyi.project.system.post.domain.Post;
import com.ruoyi.project.system.role.domain.Role;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.shiro.crypto.SecureRandomNumberGenerator;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.Date;
import java.util.List;

/**
 * @author 小新
 * @date 2020-09-17 12:21
 * @desc
 */
public class Emp extends BaseEntity{

        private static final long serialVersionUID = 1L;

        /** 员工ID */
        @Excel(name = "员工序号", cellType = Excel.ColumnType.NUMERIC, prompt = "员工编号")
        private Long empId;

        /** 部门ID */
        @Excel(name = "部门编号", type = Excel.Type.IMPORT)
        private Long deptId;

        /** 部门父ID */
        private Long parentId;

        /** 角色ID */
        private Long roleId;

        /** 员工名称 */
        @Excel(name = "员工名称")
        private String empName;


        /** 员工类型id */
        @Excel(name = "员工类型")
        private Long postId;

        /** 员工邮箱 */
        @Excel(name = "员工邮箱")
        private String email;

        /** 手机号码 */
        @Excel(name = "手机号码")
        private String phonenumber;

        /** 员工性别 */
        @Excel(name = "员工性别", readConverterExp = "0=男,1=女,2=未知")
        private String sex;

        /** 员工头像 */
        private String avatar;

        /** 员工状态（0在职 1离职） */
        @Excel(name = "员工状态", readConverterExp = "0=在职,1=离职")
        private String status;

        /** 删除标志（0代表存在 2代表删除） */
        private String delFlag;

        /** 部门对象 */
        @Excels({
                @Excel(name = "部门名称", targetAttr = "deptName", type = Excel.Type.EXPORT),
                @Excel(name = "部门负责人", targetAttr = "leader", type = Excel.Type.EXPORT)
        })


        private Dept dept;

        private Post post;

        private List<Role> roles;

        /** 角色组 */
        private Long[] roleIds;

        /** 岗位组 */
        private Long[] postIds;

        public Emp()
        {

        }

        public Emp(Long empId)
        {
            this.empId = empId;
        }

        public Long getEmpId()
        {
            return empId;
        }

        public Long getPostId() {
            return postId;
        }

        public void setPostId(Long postId) {
            this.postId = postId;
        }

    public void setEmpId(Long empId)
        {
            this.empId = empId;
        }

        public boolean isAdmin()
        {
            return isAdmin(this.empId);
        }

        public static boolean isAdmin(Long userId)
        {
            return userId != null && 1L == userId;
        }

        public Long getDeptId()
        {
            return deptId;
        }

        public void setDeptId(Long deptId)
        {
            this.deptId = deptId;
        }

        public Long getParentId()
        {
            return parentId;
        }

        public void setParentId(Long parentId)
        {
            this.parentId = parentId;
        }

        public Long getRoleId()
        {
            return roleId;
        }

        public void setRoleId(Long roleId)
        {
            this.roleId = roleId;
        }



    @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
        public String getEmpName()
        {
            return empName;
        }

        public void setEmpName(String empName)
        {
            this.empName = empName;
        }

        @Email(message = "邮箱格式不正确")
        @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
        public String getEmail()
        {
            return email;
        }

        public void setEmail(String email)
        {
            this.email = email;
        }

        @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
        public String getPhonenumber()
        {
            return phonenumber;
        }

        public void setPhonenumber(String phonenumber)
        {
            this.phonenumber = phonenumber;
        }

        public String getSex()
        {
            return sex;
        }

        public void setSex(String sex)
        {
            this.sex = sex;
        }

        public String getAvatar()
        {
            return avatar;
        }

        public void setAvatar(String avatar)
        {
            this.avatar = avatar;
        }


        public String getStatus()
        {
            return status;
        }

        public void setStatus(String status)
        {
            this.status = status;
        }

        public String getDelFlag()
        {
            return delFlag;
        }

        public void setDelFlag(String delFlag)
        {
            this.delFlag = delFlag;
        }


        public Dept getDept()
        {
            if (dept == null)
            {
                dept = new Dept();
            }
            return dept;
        }

        public void setDept(Dept dept)
        {
            this.dept = dept;
        }

        public Post getPost()
        {
            if (post == null)
            {
                post = new Post();
            }
            return post;
        }

        public void setPost(Post post)
        {
            this.post = post;
        }

        public List<Role> getRoles()
        {
            return roles;
        }

        public void setRoles(List<Role> roles)
        {
            this.roles = roles;
        }


        public Long[] getRoleIds()
        {
            return roleIds;
        }

        public void setRoleIds(Long[] roleIds)
        {
            this.roleIds = roleIds;
        }

        public Long[] getPostIds()
        {
            return postIds;
        }

        public void setPostIds(Long[] postIds)
        {
            this.postIds = postIds;
        }

        @Override
        public String toString() {
            return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                    .append("EmpId", getEmpId())
                    .append("deptId", getDeptId())
                    .append("empName", getEmpName())
                    .append("email", getEmail())
                    .append("phonenumber", getPhonenumber())
                    .append("sex", getSex())
                    .append("avatar", getAvatar())
                    .append("status", getStatus())
                    .append("delFlag", getDelFlag())
                    .append("createBy", getCreateBy())
                    .append("createTime", getCreateTime())
                    .append("updateBy", getUpdateBy())
                    .append("updateTime", getUpdateTime())
                    .append("remark", getRemark())
                    .append("dept", getDept())
                    .toString();
        }

    }


